using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib;

namespace _dmis
{
  
    public partial class RenterEdit : _dmis.WinPart
    {
        Owner m_owner;
        Renter m_renter;
        public RenterEdit(Renter renter,Owner owner)
        {
            InitializeComponent();
            m_owner = owner;
            m_renter = renter;
            gendersBindingSource.DataSource = Genders.GetGenders();
            this.rentersBindingSource.DataSource = m_renter;
        }

        #region WinPart Code

        protected internal override object GetIdValue()
        {
            return m_renter;
        }

        public override string ToString()
        {
            return m_renter.ID.ToString();
        }

        private void ResourceEdit_CurrentPrincipalChanged(object sender, EventArgs e)
        {
            ApplyAuthorizationRules();
        }
        #endregion

        private void ApplyAuthorizationRules()
        {
            // have the controls enable/disable/etc
            /* this.ReadWriteAuthorization1.ResetControlAuthorization();

             bool canEdit = ProjectTracker.Library.Project.CanEditObject();

             // enable/disable appropriate buttons
             this.OKButton.Enabled = canEdit;
             this.ApplyButton.Enabled = canEdit;
             this.Cancel_Button.Enabled = canEdit;

             // enable/disable role column in grid
             this.AssignmentsDataGridView.Columns[3].ReadOnly = !canEdit;*/
        }


        private void tsb_save_Click(object sender, EventArgs e)
        {
            m_owner.Renters.Add(m_renter);
            this.Close();
        }

        private void tsb_close_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void RenterEdit_Load(object sender, EventArgs e)
        {
            
        }
    }
}

